var jForm = {
	checkAll : function(element) {
		if (jQuery(element).is(':checked') == false) {			
			jQuery('input[name="cid[]"]').attr('checked', false);
		} else {
			jQuery('input[name="cid[]"]').attr('checked', true);
		}
		
	},
	submitForm : function() {	
		var check = true;
		jQuery('#adminForm input, #adminForm select').each(function(){	
			if (typeof jQuery(this).attr('class') !== 'undefined') {			
				if (jQuery(this).attr('class').indexOf('required') != -1) {
					if (jQuery(this).val() == '') {
						jQuery(this).css({'border-color':'orange'});
						check = false;
					} else {
						jQuery(this).css({'border-color':'#A5ACB2'});						
					}
				}	
			} 
		});
		
		if (check == false) return ;
		jQuery('#adminForm').submit();
	},
	convertToSlug : function(element, eleSlug) {	
		var str = jQuery(element).val();
	    str = str.replace(/^\s+|\s+$/g, ''); 
	    str = str.toLowerCase();
	    var from = "àáạảãâầấậẩẫăằắặẳẵèéẹẻẽêềếệểễìíịỉĩòóọỏõôồốộổỗơờớợởỡùúụủũưừứựửữỳýỵỷỹđ·/_,:;";
	    var to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyd------";
	    for (var i = 0, l = from.length; i < l; i++) {
	        str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
	    }
	    str = str.replace(/[^a-z0-9\s-]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-');	
		jQuery('input[name="jform[alias]"]').val(str);  
	}	
};

function updateImageEditor(editor, imgsrc) {
	 CKEDITOR.instances[editor].insertHtml('<img src="'+imgsrc+'" />');
}
